package com.boboPlanet.xxl.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/2/18
 **/
@Configuration
public class XxlJobRabbitMqConfig {

    //队列、交换机  topic模式
    public static final String Xxl_Send_User_State_Queue = "xxl-send-heartbeat-to-user-middle";
    public static final String Xxl_Send_User_State_Exchange = "xxl-send-user-state-top-exchange";
    public static final String Xxl_Send_User_State_Routing_Key = "xxl-send-user-state-routingKey";

    public XxlJobRabbitMqConfig(){}

    @Bean
    public Queue xxlSendUserStateQueue(){
        return new Queue(Xxl_Send_User_State_Queue,true);
    }

    @Bean
    TopicExchange xxlSendUserStateExchange() {
        return new TopicExchange(Xxl_Send_User_State_Exchange,true,false);
    }

    /**
     * todo:路由绑定交换机(routing-key)
     * @return Binding
     */
    @Bean
    Binding xxlSendUserStateBindingExchange() {
        return BindingBuilder.bind(this.xxlSendUserStateQueue()).to(this.xxlSendUserStateExchange()).with(Xxl_Send_User_State_Routing_Key);
    }

}
